home *** CD-ROM | disk | FTP | other *** search
- 100 'Periodic Balance ("PERBALANCE")
- 110 CLS
- 120 COLOR 0,15 : PRINT "Periodic Balance" : COLOR 15,0
- 130 DEFDBL A-Z
- 140 DEFINT M-N
- 150 MONEYFMT$ = "$$##,###,###.##"
- 160 PRINT
- 170 PRINT "Do not enter dollar signs or commas"
- 180 PRINT
- 190 ' Let user enter data
- 200 INPUT "Starting balance: ", SBALANCE
- 210 INPUT "Deposit each period: ", DEPOSIT
- 220 INPUT "Annual interest rate (in percent): ", AR
- 230 INPUT "Number of years: ", NYEARS
- 240 INPUT "Number of deposits per year: ", NPY
- 250 INPUT "Annual inflation rate (in percent): ", INFLATION
- 260 INPUT "Marginal tax rate (in percent): ", TAXRATE
- 270 ' Initialize values
- 280 PR = (1 + AR / 100) ^ (1 / NPY) - 1 'Interest rate per period
- 290 PR = PR * (1 - TAXRATE / 100) 'After-tax interest rate
- 300 ' Find balance at end of term
- 310 TOTALYEARS = TOTALYEARS + NYEARS
- 320 EBALANCE = SBALANCE * (1 + PR) ^ (NYEARS * NPY)
- 330 IF PR <> 0 THEN EBALANCE = EBALANCE + DEPOSIT * ( (1 + PR) ^ (NYEARS * NPY) - 1 ) * (1 + PR) / PR ELSE EBALANCE = EBALANCE + NYEARS * NPY * DEPOSIT
- 340 'Adjust for inflation
- 350 ADJUSTEDBAL = EBALANCE * ( (1 + INFLATION / 100) ^ (1 / NPY) ) ^ (-TOTALYEARS * NPY)
- 360 ' Print results
- 370 PRINT
- 380 PRINT "Year: "; TOTALYEARS
- 390 PRINT "Final balance "; TAB(30); USING MONEYFMT$; EBALANCE
- 400 PRINT "Inflation-adjusted balance "; TAB(30); USING MONEYFMT$; ADJUSTEDBAL
- 410 ' Let user continue additional periods
- 420 PRINT
- 430 PRINT "Enter Y to continue, N to stop"
- 440 K$ = INKEY$: IF K$ = "" THEN GOTO 440 ELSE IF INSTR("YyNn", K$) = 0 THEN GOTO 430
- 450 IF K$ = "N" OR K$ = "n" THEN END
- 460 CLS
- 470 'Let user enter new data
- 480 INPUT "Deposit each period: ", DEPOSIT
- 490 INPUT "Annual interest rate (in percent): ", AR
- 500 INPUT "Number of additional years: ", NYEARS
- 510 SBALANCE = EBALANCE 'Starting balance is previous final balance
- 520 GOTO 280 'Repeat calculations
- 530 END